package com.rcadmin.busi.templateapi.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.rcadmin.busi.web.dao.BlockVarDao;
import com.rcadmin.busi.web.ddl.WebBlockVar;

/**
 * 网站块关联参数
 * 
 * @author tansonlam
 * @createDate 2016年6月2日
 * 
 */
@Repository("webBlockVarService")
public class WebBlockVarService {
	@Resource
	private BlockVarDao webBlockVarDao;

	/**
	 * 批量获取网页块关联参数
	 * 
	 * @param webBlockIds
	 * @return
	 */
	public Map<Integer, List<WebBlockVar>> getBlockVars(
			List<Integer> webBlockIds) {
		Map<Integer, List<WebBlockVar>> groupMap = new HashMap<Integer, List<WebBlockVar>>();
		List<WebBlockVar> blockVarList = webBlockVarDao
				.getBlockVars(webBlockIds);
		if (blockVarList == null)
			return groupMap;

		for (WebBlockVar webBlockVar : blockVarList) {
			List<WebBlockVar> list = groupMap.get(webBlockVar.getWebBlockId());
			if (list == null) {
				list = new ArrayList<WebBlockVar>();
				groupMap.put(webBlockVar.getWebBlockId(), list);
			}
			list.add(webBlockVar);
		}
		return groupMap;
	}
}
